/**
 * 
 */
package com.epoint.mobileoa.ui.main;

import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.epoint.mobileoa.R;
import com.epoint.mobileoa.bizlogic.GVIcon;
import com.epoint.mobileoa.bizlogic.SuperView;

/**
 * MobileOA3.0
 * @author liyc
 * @time 2013-1-4 下午5:21:55 
 */
public class MainViewGvAdapter extends BaseAdapter{

	
	public SuperView con;
	public List<GVIcon> list;
	public MainViewGvAdapter(SuperView con,List<GVIcon> list)
	{
		this.con = con;
		this.list = list;
	}

	@Override
	public int getCount() {

		return list.size();

	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			LayoutInflater mInflater = LayoutInflater.from(con.getContext());
			convertView = mInflater.inflate(R.layout.iconlayout, null);

			holder.iv = (ImageView) convertView
					.findViewById(R.id.ivIcoImg);
			holder.tv = (TextView) convertView.findViewById(R.id.tvIcoTitle);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		GVIcon iifo = list.get(position);

		holder.iv.setImageResource(iifo.iconImage);
		holder.tv.setText(iifo.iconTitle);

		if(con.getBackgroundStr().equals("background")){
			holder.tv.setTextColor(con.getResources().getColor(R.color.realwhite));
		}
		else{
			holder.tv.setTextColor(con.getResources().getColor(R.color.dark_blue));
		}

		return convertView;
	}

	public class ViewHolder {
		public ImageView iv;
		public TextView tv;
	}
}
